package br.com.caelum.tarefas.interceptor;

import br.com.caelum.tarefas.modelo.Usuario;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;

@SuppressWarnings("serial")
public class AutorizadorInterceptor implements Interceptor {
	
	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		Usuario usuarioLogado = (Usuario)invocation.getInvocationContext().getSession().
				get("usuarioLogado");
		if (usuarioLogado == null) {
			return "naoLogado";
		}
		
		return invocation.invoke();
		
	}

	public void destroy() {
		
	}

	public void init() {
		
	}
}
